<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html class="zh-cn zh cn" lang="zh-cn">
<head>
	<%@ include file="../head.jsp"%>
    <link rel="stylesheet" type="text/css" href="/resource/css/validationEngine.jquery.css" />
    <link rel="stylesheet" type="text/css" href="/resource/css/template.css" />
	<script src="/resource/js/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"></script>
	<script src="/resource/js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>
<style type="text/css"> 
<!--
.edittrLefttd{
	vertical-align: top;
	float: right;
	padding: 5px 10px 5px 5px;
}
.edittrRighttd{
	width: 80%;
	padding: 5px 0px 5px 3px;
}
-->
</style>
</head>
<body class="vday home">
	<div id="page">
	<%@ include file="../global_navi.jsp"%>
	<%@ include file="../aos_header.jsp"%>
	<%@ include file="../guide.jsp"%>
		<div id="primary">
			<div id="primary_main" role="main">
				<div class="box product-shelf">
					<div class="box-content clearfix">
						<TABLE BORDER=0 WIDTH=401 CELLPADDING=0 CELLSPACING=0>
							<TR VALIGN=TOP>
								<TD WIDTH=401 COLSPAN=3>
									<img src="/resource/style/xpdd/act/image/step_title.gif"
										height="35" width="463" alt="步骤" />
								</TD>
							</TR>
							<TR VALIGN=TOP>
								<TD WIDTH=80></TD>
								<TD WIDTH=450 VALIGN=top>
									<img src="/resource/style/xpdd/act/image/step_1.gif"
										height="60" width="440" alt="全局设置" />
								</TD>
								<TD WIDTH=145 VALIGN=BOTTOM ALIGN=CENTER></TD>
							</TR>
						</TABLE>
						<br />

						<form id="propertyForm" method="POST" action="/activity/globalmodify" onsubmit="showLoading();">
							<table style="width: 100%;">
								<tr>
                            		<td class="edittrLefttd">
										<font face="'Lucida Grande', Verdana, Helvetica, sans-serif" size="1">
										<span class=L10>开始时间</span></font>
                            		</td>
                            		<td class="edittrRighttd">
                        				<fmt:formatDate value="${global.beginTime }" pattern="yyyy-MM-dd" var="beginDate"/>
                        				<input class="firstNameField" type=text size="30" value="${beginDate}" id="beginTime" name="beginTime"/>
                            		</td>
                            	</tr>
                            	<tr>
                            		<td class="edittrLefttd">
                            			<font face="'Lucida Grande', Verdana, Helvetica, sans-serif" size="1">
										<span class=L10>终止时间</span></font>
                            		</td>
                            		<td class="edittrRighttd">
                            			<fmt:formatDate value="${global.endTime }" pattern="yyyy-MM-dd" var="endDate"/>
                          				<INPUT type=text size="30" class="firstNameField validate[required,custom[date],future[now]]" value="${endDate}" name="endTime" id="endTime"/>
                            		</td>
                            	</tr>
                            	<!-- 
								<tr>
									<td class="edittrLefttd">
										<font face="'Lucida Grande', Verdana, Helvetica, sans-serif" size="1">
										<span class=L10>活动隐私</span></font>
									</td>
                                    <td class="edittrRighttd" nowrap="nowrap">
										<select name="actScope" id="actScope" >
											<option value="0">所有人</option>
											<option value="1">注册淘宝的用户</option>
											<option value="2">购买商品的用户</option>
										</select>
									</td>
								</tr>
								 -->
								<tr>
									<td class="edittrLefttd">
										<font face="'Lucida Grande', Verdana, Helvetica, sans-serif" size="1">
										<span class=L10>公告</span></font>
									</td>
									<td class="edittrRighttd">
										<textarea rows="4" cols="35" name="notice" id="notice" class="validate[optional,maxSize[256]]">${global.notice}</textarea>
									</td>
								</tr>

								<tr>
									<td class="edittrLefttd">
										<font face="'Lucida Grande', Verdana, Helvetica, sans-serif" size="1">活动状态</font>
									</td>
									<td class="edittrRighttd" id="statusRight">
										<c:if test="${global.status == 0}">
											未开始
										</c:if>
										<c:if test="${global.status == 1}">
											进行中
										</c:if>
										<c:if test="${global.status == 2}">
											已结束
										</c:if>
										<c:if test="${global.status == 3}">
											暂停
										</c:if>

									</td>
								</tr>

                            </table>

							<input type="hidden" name="beginTime" id="beginTime" value="${beginDate}" />
							<input type="hidden" name="globalId" value="${global.id }"/>

							<div style="padding-left:41%;padding-bottom: 15px;" id="editDiv">
								<input type="button"" id="editButton" value="编辑"/>
								<input type="button" value="返回" onclick="javascript:history.back();"/>
							</div>						
						</form>
										<div style="display: none;" id="statusDIV">
										<select name="status" id="status">
											<option value="0">未开始</option>
											<option value="1">进行中</option>
											<option value="2">已结束</option>
											<option value="3">暂停</option>
										</select>
										</div>
					</div>
					
					<div class="top-corners"></div>
					<div class="bottom-corners"></div>
				</div>
				<ul class="home-page-banners clearfix"></ul>
			</div>
			<div id="secondary" class="rail"><!-- 右侧功能菜单 -->
				<div role="navigation" aria-label="New Items" class="box navigation-list new-to-store">
					<div class="title-bar">
						<h2>操作</h2>
					</div>
					<div class="box-content clearfix">
						<div class="list_content">
							<ul>
                                <c:if test="${rightCode == 3 }">
									<li><a href="/activity/globalSuspend" onclick="singleLoading();">暂停</a></li>
									<li><a href="/activity/globalResume" onclick="singleLoading();">继续</a></li>
                                </c:if>
								<li><a href="javascript:void(0);" onclick="editGlobal();">修改</a></li>
							</ul>
						</div>
					</div>
					<div class="bottom-corners"></div>
				</div>

				<div class="box navigation-list top-sellers"></div>
				<div class="module footerblock" ></div>
			</div>
		</div>
		<%@ include file="../left_navi.jsp"%><!-- 左侧导航 begin -->
		<span class="shrinkwrapfix"></span>
		<%@ include file="../footer.jsp"%><!-- 左侧导航 end -->
	</div>
<script type="text/javascript">
//<![CDATA[
jQuery(document).ready(function(){
	//设置当前路径
	jQuery("#breadcrumb").append('<li><span>:&nbsp;&nbsp;全局设置</span></li>');
	
	//隐私等级
	//var act_scope = ${global.range};
	//jQuery("#actScope").val(act_scope);
	var noticeVal = '${global.notice}';
	jQuery("#notice").val(noticeVal);
	var globalStatus = ${global.status};
	jQuery("#status").val(globalStatus);
	//jQuery("#status").attr("CONTENTEDITABLE", "false");
	jQuery("#notice").attr("CONTENTEDITABLE", "false");
	//jQuery("#actScope").attr("CONTENTEDITABLE", "false");

	//时间框不可输入
	jQuery("#beginTime").attr("CONTENTEDITABLE", "false");
	jQuery("#endTime").attr("CONTENTEDITABLE", "false");

	jQuery("#editButton").click(function(){
		editGlobal();
	});
	//tooltip window
	jQuery( "#dialog-message" ).dialog({
        autoOpen : false,
        modal: true,
        buttons: {
            Ok: function() {
                $(this).dialog("close");
            }
        }
    });

});
function editGlobal()
{
    jQuery("#beginTime").attr("CONTENTEDITABLE", "true");
    jQuery("#endTime").attr("CONTENTEDITABLE", "true");
    //jQuery("#actScope").attr("CONTENTEDITABLE", "true");
    //jQuery("#status").attr("CONTENTEDITABLE", "true");
    jQuery("#statusRight").html(jQuery("#statusDIV").html());
	//jQuery("#status").css("display", "true");
    jQuery("#notice").attr("CONTENTEDITABLE", "true");
    jQuery("#beginTime").datepicker({dateFormat: 'yy-mm-dd'});
    jQuery("#endTime").datepicker({dateFormat: 'yy-mm-dd'});
    jQuery("#editDiv").html('<input type="reset"" value="重置"/>&nbsp;&nbsp;<input type="submit" value="提交"/>');
    jQuery("#propertyForm").validationEngine({
        validationEventTrigger: "submit",
        promptPosition: "centerRight"
    });
}

function showLoading(){
   if( jQuery("#propertyForm").validationEngine('validate'))
    {
	    var beginDa = jQuery("#beginTime").val().split("-");
	    var endDa = jQuery("#endTime").val().split("-");
	    var beginT = new Date(new Date(beginDa[0], (beginDa[1] - 1) ,beginDa[2]));
	    var endT = new Date(new Date(endDa[0], (endDa[1] - 1) ,endDa[2]));
	    if (beginT > endT)
    	{
	    	jQuery( "#dialog-message" ).dialog("open");
	    	return false;
    	}
        jQuery("#nyroDiv a").nmCall();
    }
}
function singleLoading(){
    jQuery("#nyroDiv a").nmCall();
}
//]]>
</script>
<div id="dialog-message" title="create activity success">
    <p>开始时间不能大于结束时间!</p>
</div>
</body>
</html>
